package live.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;

public class OrderStatusTag extends TagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6969352492731483743L;
	private String orderStatus;
	private String type;

	public String getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(String orderStatus) throws JspException {
		this.orderStatus = (String) ExpressionEvaluatorManager.evaluate(
				"orderStatus", orderStatus, Object.class, this,
				this.pageContext);
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Override
	public int doEndTag() throws JspException {
		// TODO Auto-generated method stub
		String result = "";
		int os = Integer.parseInt(getOrderStatus());
		if (type.toUpperCase().equals("ORDER")) {
			switch (os) {
			case -6:
				result = "审核失败";
				break;
			case -5:
				result = "等待审核";
				break;
			case -4:
				result = "订位失败";
				break;
			case -3:
				result = "等待订位";
				break;
			case -2:
				result = "特价审核";
				break;
			case -1:
				result = "关闭订单";
				break;
			case 0:
				result = "<font style='color:red'>等待支付</font>&nbsp;&nbsp;";
				break;
			case 1:
				result = "支付完成";
				break;
			case 2:
				result = "出票完成";
				break;
			case 3:
				result = "申请退款";
				break;
			case 4:
				result = "退款成功";
				break;
			case 5:
				result = "暂不能出票";
				break;
			case 6:
				result = "暂不能退废";
				break;
			case 7:
				result = "航班延误";
				break;
			case 8:
				result = "航班取消";
				break;
			}
		} 
		else if(type.toUpperCase().equals("ITIN")){
			switch (os) {
			case 0:
				result="等待支付";
				break;
			case 1:
				result="支付成功";
				break;
			case 2:
				result="行程单已打印";
				break;
			case 3:
				result="行程单已寄出";
				break;
			}
		}
		try {
			this.pageContext.getOut().write(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return super.doEndTag();
	}

	public static void main(String[] args) {
		int i = Integer.parseInt("-13");
		System.out.println(i);
	}

}
